package org.jeecg.modules.demo.com.kunpeng.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.com.kunpeng.entity.dto.UpdateOaProjectPurchaseDTO;
import org.jeecg.modules.demo.com.kunpeng.service.IProjectPurchaseService;
import org.jeecg.modules.demo.com.kunpeng.vo.OaProjectPurchasePage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags="OA项目采购表")
@RestController
@RequestMapping("/com.kunpeng/oaProjectPurchase")
@Slf4j
public class OaProjectPurchaseController {

    @Autowired
    private IProjectPurchaseService projectPurchaseService;

    /**
     * 新增项目采购审批
     * @param oaProjectPurchasePage
     * @return
     */
    @ApiOperation(value = "OA项目采购表-项目采购提交审批",notes = "OA项目采购表-项目采购提交审批")
    @PostMapping(value = "/saveOaProjectPurchase")
    public Result<String> saveOaProjectPurchase(@RequestBody OaProjectPurchasePage oaProjectPurchasePage){
        System.out.println("OA项目采购新增提交数据："+oaProjectPurchasePage.toString());
        projectPurchaseService.insertOaProjectPurchase(oaProjectPurchasePage);
        return Result.ok("提交成功！");
    }

    /**
     * 修改项目采购isDelete状态
     */
    @ApiOperation(value = "OA项目采购表-修改项目采购表idDelete状态",notes = "OA项目采购表-修改项目采购表idDelete状态")
    @GetMapping(value = "/updateProjectPurchaseIsDeleteById")
    public Result<String> updateProjectPurchaseIsDeleteById(String id){
        projectPurchaseService.updateProjectPurchaseIsDeleteById(id);
        return Result.ok("删除成功!");
    }


    /**
     * 根据id修改项目采购数据
     * @param updateOaProjectPurchaseDTO
     * @return
     */
    @ApiOperation(value = "OA项目费用申请表-修改项目费用申请数据",notes = "OA项目费用申请表-修改项目费用申请数据")
    @PostMapping(value = "/updateOaProjectPurchaseById")
    public Result<String> updateOaProjectPurchaseById(@RequestBody UpdateOaProjectPurchaseDTO updateOaProjectPurchaseDTO){
        System.out.println("项目费用申请修改数据："+updateOaProjectPurchaseDTO.toString());
        projectPurchaseService.updateProjectPurchaseById(updateOaProjectPurchaseDTO);
        return Result.ok("修改成功！");
    }
}
